package com.ruoyi.web.controller.webs.test;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysDictData;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.ky450.domain.*;
import com.ruoyi.system.service.ISysDictDataService;
import com.ruoyi.system.service.ISysDictTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;

/**
 * 数据字典信息
 *
 * @author ruoyi
 */
@Api(tags = "数据字典信息管理（免登录）---测试使用")
@RestController
@RequestMapping("/webs/dict/data")
public class WebsDictDataController extends BaseController
{
    @Autowired
    private ISysDictDataService dictDataService;
    @Autowired
    private RedisCache redisCache;



    @ApiOperation("删除缓存")
    @GetMapping("/a")
    public int a() {
        int i = redisCache.deleteObject("targetTree1") ? 1 : 0;
        return redisCache.deleteObject("targetTree2") ? 1 : 0;
    }

    @ApiOperation("获取数据字典列表")
    //@PreAuthorize("@ss.hasPermi('system:dict:list')")
    @GetMapping("/list")
    public TableDataInfo list()
    {
        startPage();
        List<SysDictData> list = dictDataService.selectDictDataList(new SysDictData());
        return getDataTable(list);
    }

    /**
     * 查询字典数据详细
     */
    @ApiOperation("查询字典数据详细")
    //@PreAuthorize("@ss.hasPermi('system:dict:query')")
    @GetMapping(value = "/{dictCode}")
    public AjaxResult getInfo(@PathVariable Long dictCode)
    {
        SysDictData bean = dictDataService.getById(dictCode);
        return AjaxResult.success(bean);
    }

    /**
     * 查询字典数据详细
     */
    @ApiOperation("Model描述")
    //@PreAuthorize("@ss.hasPermi('system:dict:query')")
    @PostMapping(value = "/model")
    public AjaxResult model(@RequestBody EquipAircraft aircraft,
                            @RequestBody EquipArmoredVehicle armoredVehicle,
                            @RequestBody EquipCannon cannon,
                            @RequestBody EquipMissile missile,
                            @RequestBody EquipRadar radar,
                            @RequestBody EquipShip ship)
    {
        return AjaxResult.success();
    }
}
